<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Linux常用操作01 | 小黑博客</title><meta name="keywords" content="树莓派,linux"><meta name="author" content="BluesYoung-web"><meta name="copyright" content="BluesYoung-web"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="命令别名固化12345678# 进入用户家目录cd ~# 编辑预处理文件nano .bashrc# 末尾加入命令# eg:   alias cls&#x3D;&amp;#x27;clear&amp;#x27;;# 更新配置source .bashrc  安装 node1234567# 安装 nvmcurl -o- https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;nvm-sh&#x2F;nvm&#x2F;v0.38.0&#x2F;in">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux常用操作01">
<meta property="og:url" content="https://bluesyoung-web.gitee.io/blog/2021-06-12-Linux%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C01.html">
<meta property="og:site_name" content="小黑博客">
<meta property="og:description" content="命令别名固化12345678# 进入用户家目录cd ~# 编辑预处理文件nano .bashrc# 末尾加入命令# eg:   alias cls&#x3D;&amp;#x27;clear&amp;#x27;;# 更新配置source .bashrc  安装 node1234567# 安装 nvmcurl -o- https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;nvm-sh&#x2F;nvm&#x2F;v0.38.0&#x2F;in">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://bluesyoung-web.gitee.io/blog/img/shumeipai_cover.jpg">
<meta property="article:published_time" content="2021-06-12T09:38:49.000Z">
<meta property="article:modified_time" content="2021-08-08T08:21:53.394Z">
<meta property="article:author" content="BluesYoung-web">
<meta property="article:tag" content="树莓派">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://bluesyoung-web.gitee.io/blog/img/shumeipai_cover.jpg"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://bluesyoung-web.gitee.io/blog/2021-06-12-Linux%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C01"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: BluesYoung-web","link":"链接: ","source":"来源: 小黑博客","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"top-right"},
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Linux常用操作01',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2021-08-08 16:21:53'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/blog/css/background.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/HexoStaticFile@latest/Hexo/css/custom.min.css"></link><meta name="generator" content="Hexo 5.4.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/blog/img/shumeipai.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">小黑博客</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Linux常用操作01</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-06-12T09:38:49.000Z" title="发表于 2021-06-12 17:38:49">2021-06-12</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-08-08T08:21:53.394Z" title="更新于 2021-08-08 16:21:53">2021-08-08</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/%E6%A0%91%E8%8E%93%E6%B4%BE/">树莓派</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.9k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>17分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h2 id="命令别名固化"><a href="#命令别名固化" class="headerlink" title="命令别名固化"></a>命令别名固化</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 进入用户家目录</span></span><br><span class="line"><span class="built_in">cd</span> ~</span><br><span class="line"><span class="comment"># 编辑预处理文件</span></span><br><span class="line">nano .bashrc</span><br><span class="line"><span class="comment"># 末尾加入命令</span></span><br><span class="line"><span class="comment"># eg:   alias cls=&#x27;clear&#x27;;</span></span><br><span class="line"><span class="comment"># 更新配置</span></span><br><span class="line"><span class="built_in">source</span> .bashrc</span><br></pre></td></tr></table></figure>

<h2 id="安装-node"><a href="#安装-node" class="headerlink" title="安装 node"></a>安装 node</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 安装 nvm</span></span><br><span class="line">curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash</span><br><span class="line"><span class="comment"># 装载 nvm(配置环境变量)</span></span><br><span class="line"><span class="built_in">export</span> NVM_DIR=<span class="string">&quot;<span class="subst">$([ -z <span class="string">&quot;<span class="variable">$&#123;XDG_CONFIG_HOME-&#125;</span>&quot;</span> ] &amp;&amp; printf %s <span class="string">&quot;<span class="variable">$&#123;HOME&#125;</span>/.nvm&quot;</span> || printf %s <span class="string">&quot;<span class="variable">$&#123;XDG_CONFIG_HOME&#125;</span>/nvm&quot;</span>)</span>&quot;</span></span><br><span class="line">[ -s <span class="string">&quot;<span class="variable">$NVM_DIR</span>/nvm.sh&quot;</span> ] &amp;&amp; \. <span class="string">&quot;<span class="variable">$NVM_DIR</span>/nvm.sh&quot;</span> <span class="comment"># This loads nvm</span></span><br><span class="line"><span class="comment"># 安装 node</span></span><br><span class="line">nvm install node版本号</span><br></pre></td></tr></table></figure>

<h3 id="安装脚本的内容"><a href="#安装脚本的内容" class="headerlink" title="安装脚本的内容"></a>安装脚本的内容</h3><ul>
<li>离线状态直接使用下面的脚本</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br><span class="line">457</span><br><span class="line">458</span><br><span class="line">459</span><br><span class="line">460</span><br><span class="line">461</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/usr/bin/env bash</span></span><br><span class="line"></span><br><span class="line">&#123; <span class="comment"># this ensures the entire script is downloaded #</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_has</span></span>() &#123;</span><br><span class="line">  <span class="built_in">type</span> <span class="string">&quot;<span class="variable">$1</span>&quot;</span> &gt; /dev/null 2&gt;&amp;1</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_echo</span></span>() &#123;</span><br><span class="line">  <span class="built_in">command</span> <span class="built_in">printf</span> %s\\n <span class="string">&quot;$*&quot;</span> 2&gt;/dev/null</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_grep</span></span>() &#123;</span><br><span class="line">  GREP_OPTIONS=<span class="string">&#x27;&#x27;</span> <span class="built_in">command</span> grep <span class="string">&quot;<span class="variable">$@</span>&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_default_install_dir</span></span>() &#123;</span><br><span class="line">  [ -z <span class="string">&quot;<span class="variable">$&#123;XDG_CONFIG_HOME-&#125;</span>&quot;</span> ] &amp;&amp; <span class="built_in">printf</span> %s <span class="string">&quot;<span class="variable">$&#123;HOME&#125;</span>/.nvm&quot;</span> || <span class="built_in">printf</span> %s <span class="string">&quot;<span class="variable">$&#123;XDG_CONFIG_HOME&#125;</span>/nvm&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_install_dir</span></span>() &#123;</span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$NVM_DIR</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">printf</span> %s <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    nvm_default_install_dir</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_latest_version</span></span>() &#123;</span><br><span class="line">  nvm_echo <span class="string">&quot;v0.38.0&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_profile_is_bash_or_zsh</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> TEST_PROFILE</span><br><span class="line">  TEST_PROFILE=<span class="string">&quot;<span class="variable">$&#123;1-&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">case</span> <span class="string">&quot;<span class="variable">$&#123;TEST_PROFILE-&#125;</span>&quot;</span> <span class="keyword">in</span></span><br><span class="line">    *<span class="string">&quot;/.bashrc&quot;</span> | *<span class="string">&quot;/.bash_profile&quot;</span> | *<span class="string">&quot;/.zshrc&quot;</span>)</span><br><span class="line">      <span class="built_in">return</span></span><br><span class="line">    ;;</span><br><span class="line">    *)</span><br><span class="line">      <span class="built_in">return</span> 1</span><br><span class="line">    ;;</span><br><span class="line">  <span class="keyword">esac</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Outputs the location to NVM depending on:</span></span><br><span class="line"><span class="comment"># * The availability of $NVM_SOURCE</span></span><br><span class="line"><span class="comment"># * The method used (&quot;script&quot; or &quot;git&quot; in the script, defaults to &quot;git&quot;)</span></span><br><span class="line"><span class="comment"># NVM_SOURCE always takes precedence unless the method is &quot;script-nvm-exec&quot;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_source</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> NVM_GITHUB_REPO</span><br><span class="line">  NVM_GITHUB_REPO=<span class="string">&quot;<span class="variable">$&#123;NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm&#125;</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_VERSION</span><br><span class="line">  NVM_VERSION=<span class="string">&quot;<span class="variable">$&#123;NVM_INSTALL_VERSION:-$(nvm_latest_version)&#125;</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_METHOD</span><br><span class="line">  NVM_METHOD=<span class="string">&quot;<span class="variable">$1</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_SOURCE_URL</span><br><span class="line">  NVM_SOURCE_URL=<span class="string">&quot;<span class="variable">$NVM_SOURCE</span>&quot;</span></span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">&quot;_<span class="variable">$NVM_METHOD</span>&quot;</span> = <span class="string">&quot;_script-nvm-exec&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    NVM_SOURCE_URL=<span class="string">&quot;https://raw.githubusercontent.com/<span class="variable">$&#123;NVM_GITHUB_REPO&#125;</span>/<span class="variable">$&#123;NVM_VERSION&#125;</span>/nvm-exec&quot;</span></span><br><span class="line">  <span class="keyword">elif</span> [ <span class="string">&quot;_<span class="variable">$NVM_METHOD</span>&quot;</span> = <span class="string">&quot;_script-nvm-bash-completion&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    NVM_SOURCE_URL=<span class="string">&quot;https://raw.githubusercontent.com/<span class="variable">$&#123;NVM_GITHUB_REPO&#125;</span>/<span class="variable">$&#123;NVM_VERSION&#125;</span>/bash_completion&quot;</span></span><br><span class="line">  <span class="keyword">elif</span> [ -z <span class="string">&quot;<span class="variable">$NVM_SOURCE_URL</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> [ <span class="string">&quot;_<span class="variable">$NVM_METHOD</span>&quot;</span> = <span class="string">&quot;_script&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      NVM_SOURCE_URL=<span class="string">&quot;https://raw.githubusercontent.com/<span class="variable">$&#123;NVM_GITHUB_REPO&#125;</span>/<span class="variable">$&#123;NVM_VERSION&#125;</span>/nvm.sh&quot;</span></span><br><span class="line">    <span class="keyword">elif</span> [ <span class="string">&quot;_<span class="variable">$NVM_METHOD</span>&quot;</span> = <span class="string">&quot;_git&quot;</span> ] || [ -z <span class="string">&quot;<span class="variable">$NVM_METHOD</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      NVM_SOURCE_URL=<span class="string">&quot;https://github.com/<span class="variable">$&#123;NVM_GITHUB_REPO&#125;</span>.git&quot;</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;Unexpected value \&quot;<span class="variable">$NVM_METHOD</span>\&quot; for \$NVM_METHOD&quot;</span></span><br><span class="line">      <span class="built_in">return</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  nvm_echo <span class="string">&quot;<span class="variable">$NVM_SOURCE_URL</span>&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Node.js version to install</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_node_version</span></span>() &#123;</span><br><span class="line">  nvm_echo <span class="string">&quot;<span class="variable">$NODE_VERSION</span>&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_download</span></span>() &#123;</span><br><span class="line">  <span class="keyword">if</span> nvm_has <span class="string">&quot;curl&quot;</span>; <span class="keyword">then</span></span><br><span class="line">    curl --fail --compressed -q <span class="string">&quot;<span class="variable">$@</span>&quot;</span></span><br><span class="line">  <span class="keyword">elif</span> nvm_has <span class="string">&quot;wget&quot;</span>; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># Emulate curl with wget</span></span><br><span class="line">    ARGS=$(nvm_echo <span class="string">&quot;<span class="variable">$@</span>&quot;</span> | <span class="built_in">command</span> sed -e <span class="string">&#x27;s/--progress-bar /--progress=bar /&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/--compressed //&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/--fail //&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-L //&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-I /--server-response /&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-s /-q /&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-sS /-nv /&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-o /-O /&#x27;</span> \</span><br><span class="line">                            -e <span class="string">&#x27;s/-C - /-c /&#x27;</span>)</span><br><span class="line">    <span class="comment"># shellcheck disable=SC2086</span></span><br><span class="line">    <span class="built_in">eval</span> wget <span class="variable">$ARGS</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">install_nvm_from_git</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> INSTALL_DIR</span><br><span class="line">  INSTALL_DIR=<span class="string">&quot;<span class="subst">$(nvm_install_dir)</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_VERSION</span><br><span class="line">  NVM_VERSION=<span class="string">&quot;<span class="variable">$&#123;NVM_INSTALL_VERSION:-$(nvm_latest_version)&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$&#123;NVM_INSTALL_VERSION:-&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># Check if version is an existing ref</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">command</span> git ls-remote <span class="string">&quot;<span class="subst">$(nvm_source <span class="string">&quot;git&quot;</span>)</span>&quot;</span> <span class="string">&quot;<span class="variable">$NVM_VERSION</span>&quot;</span> | nvm_grep -q <span class="string">&quot;<span class="variable">$NVM_VERSION</span>&quot;</span> ; <span class="keyword">then</span></span><br><span class="line">      :</span><br><span class="line">    <span class="comment"># Check if version is an existing changeset</span></span><br><span class="line">    <span class="keyword">elif</span> ! nvm_download -o /dev/null <span class="string">&quot;<span class="subst">$(nvm_source <span class="string">&quot;script-nvm-exec&quot;</span>)</span>&quot;</span>; <span class="keyword">then</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to find &#x27;<span class="variable">$NVM_VERSION</span>&#x27; version.&quot;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> fetch_error</span><br><span class="line">  <span class="keyword">if</span> [ -d <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/.git&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># Updating repo</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; nvm is already installed in <span class="variable">$INSTALL_DIR</span>, trying to update using git&quot;</span></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&#x27;\r=&gt; &#x27;</span></span><br><span class="line">    fetch_error=<span class="string">&quot;Failed to update nvm with <span class="variable">$NVM_VERSION</span>, run &#x27;git fetch&#x27; in <span class="variable">$INSTALL_DIR</span> yourself.&quot;</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    fetch_error=<span class="string">&quot;Failed to fetch origin with <span class="variable">$NVM_VERSION</span>. Please report this!&quot;</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Downloading nvm from git to &#x27;<span class="variable">$INSTALL_DIR</span>&#x27;&quot;</span></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&#x27;\r=&gt; &#x27;</span></span><br><span class="line">    mkdir -p <span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>&quot;</span></span><br><span class="line">    <span class="keyword">if</span> [ <span class="string">&quot;<span class="subst">$(ls -A <span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>&quot;</span>)</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      <span class="comment"># Initializing repo</span></span><br><span class="line">      <span class="built_in">command</span> git init <span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>&quot;</span> || &#123;</span><br><span class="line">        nvm_echo &gt;&amp;2 <span class="string">&#x27;Failed to initialize nvm repo. Please report this!&#x27;</span></span><br><span class="line">        <span class="built_in">exit</span> 2</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>/.git&quot;</span> remote add origin <span class="string">&quot;<span class="subst">$(nvm_source)</span>&quot;</span> 2&gt; /dev/null \</span><br><span class="line">        || <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>/.git&quot;</span> remote set-url origin <span class="string">&quot;<span class="subst">$(nvm_source)</span>&quot;</span> || &#123;</span><br><span class="line">        nvm_echo &gt;&amp;2 <span class="string">&#x27;Failed to add remote &quot;origin&quot; (or set the URL). Please report this!&#x27;</span></span><br><span class="line">        <span class="built_in">exit</span> 2</span><br><span class="line">      &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      <span class="comment"># Cloning repo</span></span><br><span class="line">      <span class="built_in">command</span> git <span class="built_in">clone</span> <span class="string">&quot;<span class="subst">$(nvm_source)</span>&quot;</span> --depth=1 <span class="string">&quot;<span class="variable">$&#123;INSTALL_DIR&#125;</span>&quot;</span> || &#123;</span><br><span class="line">        nvm_echo &gt;&amp;2 <span class="string">&#x27;Failed to clone nvm repo. Please report this!&#x27;</span></span><br><span class="line">        <span class="built_in">exit</span> 2</span><br><span class="line">      &#125;</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="comment"># Try to fetch tag</span></span><br><span class="line">  <span class="keyword">if</span> <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> fetch origin tag <span class="string">&quot;<span class="variable">$NVM_VERSION</span>&quot;</span> --depth=1 2&gt;/dev/null; <span class="keyword">then</span></span><br><span class="line">    :</span><br><span class="line">  <span class="comment"># Fetch given version</span></span><br><span class="line">  <span class="keyword">elif</span> ! <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> fetch origin <span class="string">&quot;<span class="variable">$NVM_VERSION</span>&quot;</span> --depth=1; <span class="keyword">then</span></span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;<span class="variable">$fetch_error</span>&quot;</span></span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="built_in">command</span> git -c advice.detachedHead=<span class="literal">false</span> --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> checkout -f --quiet FETCH_HEAD || &#123;</span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to checkout the given version <span class="variable">$NVM_VERSION</span>. Please report this!&quot;</span></span><br><span class="line">    <span class="built_in">exit</span> 2</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="subst">$(command git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> show-ref refs/heads/master)</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> branch --quiet 2&gt;/dev/null; <span class="keyword">then</span></span><br><span class="line">      <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> branch --quiet -D master &gt;/dev/null 2&gt;&amp;1</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;Your version of git is out of date. Please update it!&quot;</span></span><br><span class="line">      <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> branch -D master &gt;/dev/null 2&gt;&amp;1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  nvm_echo <span class="string">&quot;=&gt; Compressing and cleaning up git repository&quot;</span></span><br><span class="line">  <span class="keyword">if</span> ! <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> reflog expire --expire=now --all; <span class="keyword">then</span></span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Your version of git is out of date. Please update it!&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">if</span> ! <span class="built_in">command</span> git --git-dir=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span>/.git --work-tree=<span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span> gc --auto --aggressive --prune=now ; <span class="keyword">then</span></span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Your version of git is out of date. Please update it!&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="built_in">return</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Automatically install Node.js</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_install_node</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> NODE_VERSION_LOCAL</span><br><span class="line">  NODE_VERSION_LOCAL=<span class="string">&quot;<span class="subst">$(nvm_node_version)</span>&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$NODE_VERSION_LOCAL</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">return</span> 0</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  nvm_echo <span class="string">&quot;=&gt; Installing Node.js version <span class="variable">$NODE_VERSION_LOCAL</span>&quot;</span></span><br><span class="line">  nvm install <span class="string">&quot;<span class="variable">$NODE_VERSION_LOCAL</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> CURRENT_NVM_NODE</span><br><span class="line"></span><br><span class="line">  CURRENT_NVM_NODE=<span class="string">&quot;<span class="subst">$(nvm_version current)</span>&quot;</span></span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">&quot;<span class="subst">$(nvm_version <span class="string">&quot;<span class="variable">$NODE_VERSION_LOCAL</span>&quot;</span>)</span>&quot;</span> == <span class="string">&quot;<span class="variable">$CURRENT_NVM_NODE</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Node.js version <span class="variable">$NODE_VERSION_LOCAL</span> has been successfully installed&quot;</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to install Node.js <span class="variable">$NODE_VERSION_LOCAL</span>&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">install_nvm_as_script</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> INSTALL_DIR</span><br><span class="line">  INSTALL_DIR=<span class="string">&quot;<span class="subst">$(nvm_install_dir)</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_SOURCE_LOCAL</span><br><span class="line">  NVM_SOURCE_LOCAL=<span class="string">&quot;<span class="subst">$(nvm_source script)</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_EXEC_SOURCE</span><br><span class="line">  NVM_EXEC_SOURCE=<span class="string">&quot;<span class="subst">$(nvm_source script-nvm-exec)</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> NVM_BASH_COMPLETION_SOURCE</span><br><span class="line">  NVM_BASH_COMPLETION_SOURCE=<span class="string">&quot;<span class="subst">$(nvm_source script-nvm-bash-completion)</span>&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># Downloading to $INSTALL_DIR</span></span><br><span class="line">  mkdir -p <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>&quot;</span></span><br><span class="line">  <span class="keyword">if</span> [ -f <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/nvm.sh&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; nvm is already installed in <span class="variable">$INSTALL_DIR</span>, trying to update the script&quot;</span></span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Downloading nvm as script to &#x27;<span class="variable">$INSTALL_DIR</span>&#x27;&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  nvm_download -s <span class="string">&quot;<span class="variable">$NVM_SOURCE_LOCAL</span>&quot;</span> -o <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/nvm.sh&quot;</span> || &#123;</span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to download &#x27;<span class="variable">$NVM_SOURCE_LOCAL</span>&#x27;&quot;</span></span><br><span class="line">    <span class="built_in">return</span> 1</span><br><span class="line">  &#125; &amp;</span><br><span class="line">  nvm_download -s <span class="string">&quot;<span class="variable">$NVM_EXEC_SOURCE</span>&quot;</span> -o <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/nvm-exec&quot;</span> || &#123;</span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to download &#x27;<span class="variable">$NVM_EXEC_SOURCE</span>&#x27;&quot;</span></span><br><span class="line">    <span class="built_in">return</span> 2</span><br><span class="line">  &#125; &amp;</span><br><span class="line">  nvm_download -s <span class="string">&quot;<span class="variable">$NVM_BASH_COMPLETION_SOURCE</span>&quot;</span> -o <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/bash_completion&quot;</span> || &#123;</span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to download &#x27;<span class="variable">$NVM_BASH_COMPLETION_SOURCE</span>&#x27;&quot;</span></span><br><span class="line">    <span class="built_in">return</span> 2</span><br><span class="line">  &#125; &amp;</span><br><span class="line">  <span class="keyword">for</span> job <span class="keyword">in</span> $(<span class="built_in">jobs</span> -p | <span class="built_in">command</span> sort)</span><br><span class="line">  <span class="keyword">do</span></span><br><span class="line">    <span class="built_in">wait</span> <span class="string">&quot;<span class="variable">$job</span>&quot;</span> || <span class="built_in">return</span> $?</span><br><span class="line">  <span class="keyword">done</span></span><br><span class="line">  chmod a+x <span class="string">&quot;<span class="variable">$INSTALL_DIR</span>/nvm-exec&quot;</span> || &#123;</span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;Failed to mark &#x27;<span class="variable">$INSTALL_DIR</span>/nvm-exec&#x27; as executable&quot;</span></span><br><span class="line">    <span class="built_in">return</span> 3</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_try_profile</span></span>() &#123;</span><br><span class="line">  <span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$&#123;1-&#125;</span>&quot;</span> ] || [ ! -f <span class="string">&quot;<span class="variable">$&#123;1&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">return</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  nvm_echo <span class="string">&quot;<span class="variable">$&#123;1&#125;</span>&quot;</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Detect profile file if not specified as environment variable</span></span><br><span class="line"><span class="comment"># (eg: PROFILE=~/.myprofile)</span></span><br><span class="line"><span class="comment"># The echo&#x27;ed path is guaranteed to be an existing file</span></span><br><span class="line"><span class="comment"># Otherwise, an empty string is returned</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_detect_profile</span></span>() &#123;</span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">&quot;<span class="variable">$&#123;PROFILE-&#125;</span>&quot;</span> = <span class="string">&#x27;/dev/null&#x27;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># the user has specifically requested NOT to have nvm touch their profile</span></span><br><span class="line">    <span class="built_in">return</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$&#123;PROFILE&#125;</span>&quot;</span> ] &amp;&amp; [ -f <span class="string">&quot;<span class="variable">$&#123;PROFILE&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    nvm_echo <span class="string">&quot;<span class="variable">$&#123;PROFILE&#125;</span>&quot;</span></span><br><span class="line">    <span class="built_in">return</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> DETECTED_PROFILE</span><br><span class="line">  DETECTED_PROFILE=<span class="string">&#x27;&#x27;</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$&#123;BASH_VERSION-&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> [ -f <span class="string">&quot;<span class="variable">$HOME</span>/.bashrc&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      DETECTED_PROFILE=<span class="string">&quot;<span class="variable">$HOME</span>/.bashrc&quot;</span></span><br><span class="line">    <span class="keyword">elif</span> [ -f <span class="string">&quot;<span class="variable">$HOME</span>/.bash_profile&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      DETECTED_PROFILE=<span class="string">&quot;<span class="variable">$HOME</span>/.bash_profile&quot;</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">elif</span> [ -n <span class="string">&quot;<span class="variable">$&#123;ZSH_VERSION-&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    DETECTED_PROFILE=<span class="string">&quot;<span class="variable">$HOME</span>/.zshrc&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$DETECTED_PROFILE</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">for</span> EACH_PROFILE <span class="keyword">in</span> <span class="string">&quot;.profile&quot;</span> <span class="string">&quot;.bashrc&quot;</span> <span class="string">&quot;.bash_profile&quot;</span> <span class="string">&quot;.zshrc&quot;</span></span><br><span class="line">    <span class="keyword">do</span></span><br><span class="line">      <span class="keyword">if</span> DETECTED_PROFILE=<span class="string">&quot;<span class="subst">$(nvm_try_profile <span class="string">&quot;<span class="variable">$&#123;HOME&#125;</span>/<span class="variable">$&#123;EACH_PROFILE&#125;</span>&quot;</span>)</span>&quot;</span>; <span class="keyword">then</span></span><br><span class="line">        <span class="built_in">break</span></span><br><span class="line">      <span class="keyword">fi</span></span><br><span class="line">    <span class="keyword">done</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$DETECTED_PROFILE</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    nvm_echo <span class="string">&quot;<span class="variable">$DETECTED_PROFILE</span>&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Check whether the user has any globally-installed npm modules in their system</span></span><br><span class="line"><span class="comment"># Node, and warn them if so.</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_check_global_modules</span></span>() &#123;</span><br><span class="line">  <span class="built_in">local</span> NPM_COMMAND</span><br><span class="line">  NPM_COMMAND=<span class="string">&quot;<span class="subst">$(command -v npm 2&gt;/dev/null)</span>&quot;</span> || <span class="built_in">return</span> 0</span><br><span class="line">  [ -n <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span> ] &amp;&amp; [ -z <span class="string">&quot;<span class="variable">$&#123;NPM_COMMAND%%$NVM_DIR/*&#125;</span>&quot;</span> ] &amp;&amp; <span class="built_in">return</span> 0</span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> NPM_VERSION</span><br><span class="line">  NPM_VERSION=<span class="string">&quot;<span class="subst">$(npm --version)</span>&quot;</span></span><br><span class="line">  NPM_VERSION=<span class="string">&quot;<span class="variable">$&#123;NPM_VERSION:--1&#125;</span>&quot;</span></span><br><span class="line">  [ <span class="string">&quot;<span class="variable">$&#123;NPM_VERSION%%[!-0-9]*&#125;</span>&quot;</span> -gt 0 ] || <span class="built_in">return</span> 0</span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> NPM_GLOBAL_MODULES</span><br><span class="line">  NPM_GLOBAL_MODULES=<span class="string">&quot;<span class="subst">$(</span></span></span><br><span class="line"><span class="string"><span class="subst">    npm list -g --depth=0 |</span></span></span><br><span class="line"><span class="string"><span class="subst">    command sed -e &#x27;/ npm@/d&#x27; -e &#x27;/ (empty)</span>$/d&#x27;</span></span><br><span class="line"><span class="string">  )&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> MODULE_COUNT</span><br><span class="line">  MODULE_COUNT=<span class="string">&quot;<span class="subst">$(</span></span></span><br><span class="line"><span class="string"><span class="subst">    command printf %s\\n <span class="string">&quot;<span class="variable">$NPM_GLOBAL_MODULES</span>&quot;</span> |</span></span></span><br><span class="line"><span class="string"><span class="subst">    command sed -ne &#x27;1!p&#x27; |                     # Remove the first line</span></span></span><br><span class="line"><span class="string"><span class="subst">    wc -l | command tr -d &#x27; &#x27;                   # Count entries</span></span></span><br><span class="line"><span class="string"><span class="subst">  )</span>&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ <span class="string">&quot;<span class="variable">$&#123;MODULE_COUNT&#125;</span>&quot;</span> != <span class="string">&#x27;0&#x27;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; You currently have modules installed globally with `npm`. These will no&#x27;</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; longer be linked to the active version of Node when you install a new node&#x27;</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; with `nvm`; and they may (depending on how you construct your `$PATH`)&#x27;</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; override the binaries of modules installed with `nvm`:&#x27;</span></span><br><span class="line">    nvm_echo</span><br><span class="line"></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> %s\\n <span class="string">&quot;<span class="variable">$NPM_GLOBAL_MODULES</span>&quot;</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; If you wish to uninstall them at a later point (or re-install them under your&#x27;</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;=&gt; `nvm` Nodes), you can remove them from the system Node as follows:&#x27;</span></span><br><span class="line">    nvm_echo</span><br><span class="line">    nvm_echo <span class="string">&#x27;     $ nvm use system&#x27;</span></span><br><span class="line">    nvm_echo <span class="string">&#x27;     $ npm uninstall -g a_module&#x27;</span></span><br><span class="line">    nvm_echo</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="title">nvm_do_install</span></span>() &#123;</span><br><span class="line">  <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$&#123;NVM_DIR-&#125;</span>&quot;</span> ] &amp;&amp; ! [ -d <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> [ -e <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;File \&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>\&quot; has the same name as installation directory.&quot;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span> [ <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span> = <span class="string">&quot;<span class="subst">$(nvm_default_install_dir)</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      mkdir <span class="string">&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>&quot;</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;You have \$NVM_DIR set to \&quot;<span class="variable">$&#123;NVM_DIR&#125;</span>\&quot;, but that directory does not exist. Check your profile files and environment.&quot;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$&#123;METHOD&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="comment"># Autodetect install method</span></span><br><span class="line">    <span class="keyword">if</span> nvm_has git; <span class="keyword">then</span></span><br><span class="line">      install_nvm_from_git</span><br><span class="line">    <span class="keyword">elif</span> nvm_has nvm_download; <span class="keyword">then</span></span><br><span class="line">      install_nvm_as_script</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&#x27;You need git, curl, or wget to install nvm&#x27;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">elif</span> [ <span class="string">&quot;<span class="variable">$&#123;METHOD&#125;</span>&quot;</span> = <span class="string">&#x27;git&#x27;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> ! nvm_has git; <span class="keyword">then</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;You need git to install nvm&quot;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    install_nvm_from_git</span><br><span class="line">  <span class="keyword">elif</span> [ <span class="string">&quot;<span class="variable">$&#123;METHOD&#125;</span>&quot;</span> = <span class="string">&#x27;script&#x27;</span> ]; <span class="keyword">then</span></span><br><span class="line">    <span class="keyword">if</span> ! nvm_has nvm_download; <span class="keyword">then</span></span><br><span class="line">      nvm_echo &gt;&amp;2 <span class="string">&quot;You need curl or wget to install nvm&quot;</span></span><br><span class="line">      <span class="built_in">exit</span> 1</span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    install_nvm_as_script</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    nvm_echo &gt;&amp;2 <span class="string">&quot;The environment variable \$METHOD is set to \&quot;<span class="variable">$&#123;METHOD&#125;</span>\&quot;, which is not recognized as a valid installation method.&quot;</span></span><br><span class="line">    <span class="built_in">exit</span> 1</span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  nvm_echo</span><br><span class="line"></span><br><span class="line">  <span class="built_in">local</span> NVM_PROFILE</span><br><span class="line">  NVM_PROFILE=<span class="string">&quot;<span class="subst">$(nvm_detect_profile)</span>&quot;</span></span><br><span class="line">  <span class="built_in">local</span> PROFILE_INSTALL_DIR</span><br><span class="line">  PROFILE_INSTALL_DIR=<span class="string">&quot;<span class="subst">$(nvm_install_dir | command sed <span class="string">&quot;s:^<span class="variable">$HOME</span>:\$HOME:&quot;</span>)</span>&quot;</span></span><br><span class="line"></span><br><span class="line">  SOURCE_STR=<span class="string">&quot;\\nexport NVM_DIR=\&quot;<span class="variable">$&#123;PROFILE_INSTALL_DIR&#125;</span>\&quot;\\n[ -s \&quot;\$NVM_DIR/nvm.sh\&quot; ] &amp;&amp; \\. \&quot;\$NVM_DIR/nvm.sh\&quot;  # This loads nvm\\n&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">  COMPLETION_STR=<span class="string">&#x27;[ -s &quot;$NVM_DIR/bash_completion&quot; ] &amp;&amp; \. &quot;$NVM_DIR/bash_completion&quot;  # This loads nvm bash_completion\n&#x27;</span></span><br><span class="line">  BASH_OR_ZSH=<span class="literal">false</span></span><br><span class="line"></span><br><span class="line">  <span class="keyword">if</span> [ -z <span class="string">&quot;<span class="variable">$&#123;NVM_PROFILE-&#125;</span>&quot;</span> ] ; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">local</span> TRIED_PROFILE</span><br><span class="line">    <span class="keyword">if</span> [ -n <span class="string">&quot;<span class="variable">$&#123;PROFILE&#125;</span>&quot;</span> ]; <span class="keyword">then</span></span><br><span class="line">      TRIED_PROFILE=<span class="string">&quot;<span class="variable">$&#123;NVM_PROFILE&#125;</span> (as defined in \$PROFILE), &quot;</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Profile not found. Tried <span class="variable">$&#123;TRIED_PROFILE-&#125;</span>~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.&quot;</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Create one of them and run this script again&quot;</span></span><br><span class="line">    nvm_echo <span class="string">&quot;   OR&quot;</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Append the following lines to the correct file yourself:&quot;</span></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$&#123;SOURCE_STR&#125;</span>&quot;</span></span><br><span class="line">    nvm_echo</span><br><span class="line">  <span class="keyword">else</span></span><br><span class="line">    <span class="keyword">if</span> nvm_profile_is_bash_or_zsh <span class="string">&quot;<span class="variable">$&#123;NVM_PROFILE-&#125;</span>&quot;</span>; <span class="keyword">then</span></span><br><span class="line">      BASH_OR_ZSH=<span class="literal">true</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    <span class="keyword">if</span> ! <span class="built_in">command</span> grep -qc <span class="string">&#x27;/nvm.sh&#x27;</span> <span class="string">&quot;<span class="variable">$NVM_PROFILE</span>&quot;</span>; <span class="keyword">then</span></span><br><span class="line">      nvm_echo <span class="string">&quot;=&gt; Appending nvm source string to <span class="variable">$NVM_PROFILE</span>&quot;</span></span><br><span class="line">      <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$&#123;SOURCE_STR&#125;</span>&quot;</span> &gt;&gt; <span class="string">&quot;<span class="variable">$NVM_PROFILE</span>&quot;</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo <span class="string">&quot;=&gt; nvm source string already in <span class="variable">$&#123;NVM_PROFILE&#125;</span>&quot;</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">    <span class="comment"># shellcheck disable=SC2016</span></span><br><span class="line">    <span class="keyword">if</span> <span class="variable">$&#123;BASH_OR_ZSH&#125;</span> &amp;&amp; ! <span class="built_in">command</span> grep -qc <span class="string">&#x27;$NVM_DIR/bash_completion&#x27;</span> <span class="string">&quot;<span class="variable">$NVM_PROFILE</span>&quot;</span>; <span class="keyword">then</span></span><br><span class="line">      nvm_echo <span class="string">&quot;=&gt; Appending bash_completion source string to <span class="variable">$NVM_PROFILE</span>&quot;</span></span><br><span class="line">      <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$COMPLETION_STR</span>&quot;</span> &gt;&gt; <span class="string">&quot;<span class="variable">$NVM_PROFILE</span>&quot;</span></span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">      nvm_echo <span class="string">&quot;=&gt; bash_completion source string already in <span class="variable">$&#123;NVM_PROFILE&#125;</span>&quot;</span></span><br><span class="line">    <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">  <span class="keyword">if</span> <span class="variable">$&#123;BASH_OR_ZSH&#125;</span> &amp;&amp; [ -z <span class="string">&quot;<span class="variable">$&#123;NVM_PROFILE-&#125;</span>&quot;</span> ] ; <span class="keyword">then</span></span><br><span class="line">    nvm_echo <span class="string">&quot;=&gt; Please also append the following lines to the if you are using bash/zsh shell:&quot;</span></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$&#123;COMPLETION_STR&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># Source nvm</span></span><br><span class="line">  <span class="comment"># shellcheck source=/dev/null</span></span><br><span class="line">  \. <span class="string">&quot;<span class="subst">$(nvm_install_dir)</span>/nvm.sh&quot;</span></span><br><span class="line"></span><br><span class="line">  nvm_check_global_modules</span><br><span class="line"></span><br><span class="line">  nvm_install_node</span><br><span class="line"></span><br><span class="line">  nvm_reset</span><br><span class="line"></span><br><span class="line">  nvm_echo <span class="string">&quot;=&gt; Close and reopen your terminal to start using nvm or run the following to use it now:&quot;</span></span><br><span class="line">  <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$&#123;SOURCE_STR&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">if</span> <span class="variable">$&#123;BASH_OR_ZSH&#125;</span> ; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">command</span> <span class="built_in">printf</span> <span class="string">&quot;<span class="variable">$&#123;COMPLETION_STR&#125;</span>&quot;</span></span><br><span class="line">  <span class="keyword">fi</span></span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Unsets the various functions defined</span></span><br><span class="line"><span class="comment"># during the execution of the install script</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="function"><span class="title">nvm_reset</span></span>() &#123;</span><br><span class="line">  <span class="built_in">unset</span> -f nvm_has nvm_install_dir nvm_latest_version nvm_profile_is_bash_or_zsh \</span><br><span class="line">    nvm_source nvm_node_version nvm_download install_nvm_from_git nvm_install_node \</span><br><span class="line">    install_nvm_as_script nvm_try_profile nvm_detect_profile nvm_check_global_modules \</span><br><span class="line">    nvm_do_install nvm_reset nvm_default_install_dir nvm_grep</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">[ <span class="string">&quot;_<span class="variable">$NVM_ENV</span>&quot;</span> = <span class="string">&quot;_testing&quot;</span> ] || nvm_do_install</span><br><span class="line"></span><br><span class="line">&#125; <span class="comment"># this ensures the entire script is downloaded #</span></span><br></pre></td></tr></table></figure>

<h2 id="安装最新版的-git"><a href="#安装最新版的-git" class="headerlink" title="安装最新版的 git"></a>安装最新版的 git</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 前置条件，安装 add-apt-repository</span></span><br><span class="line">sudo apt-get install python-software-properties</span><br><span class="line">sudo apt-get install software-properties-common</span><br><span class="line">sudo apt-get update</span><br><span class="line"><span class="comment"># add-apt-repository 如果存在则可以跳过上面的安装步骤</span></span><br><span class="line">sudo add-apt-repository ppa:git-core/ppa</span><br><span class="line">sudo apt-get update</span><br><span class="line">sudo apt-get install git</span><br></pre></td></tr></table></figure>

<h2 id="安装-deb-包"><a href="#安装-deb-包" class="headerlink" title="安装 deb 包"></a>安装 deb 包</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo dpkg -i 包名称</span><br></pre></td></tr></table></figure>


<h2 id="安装-tar-gz-包"><a href="#安装-tar-gz-包" class="headerlink" title="安装 .tar.gz 包"></a>安装 <code>.tar.gz</code> 包</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 解压</span></span><br><span class="line">tar -xvf *.tar.gz</span><br><span class="line"><span class="comment"># 复制到常用的软件目录</span></span><br><span class="line">cp -ar 解压之后的目录名 ~/软件</span><br><span class="line"><span class="comment"># 转到软件目录</span></span><br><span class="line"><span class="built_in">cd</span> ~/软件/目录名</span><br><span class="line"><span class="comment"># 给目标可执行文件添加软连接</span></span><br><span class="line">sudo ln -s ~/软件/目录名/文件名 /usr/<span class="built_in">local</span>/bin/文件名</span><br><span class="line"><span class="comment"># 启动软件</span></span><br><span class="line">文件名</span><br></pre></td></tr></table></figure>

<h2 id="添加铜豌豆常用软件源"><a href="#添加铜豌豆常用软件源" class="headerlink" title="添加铜豌豆常用软件源"></a>添加铜豌豆常用软件源</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 添加软件源</span></span><br><span class="line">sudo apt-add-repository <span class="string">&#x27;deb https://apt.atzlinux.com/atzlinux buster main contrib non-free&#x27;</span></span><br><span class="line"><span class="comment"># 解决证书报错</span></span><br><span class="line">wget -O public.key https://www.atzlinux.com/atzlinux/download/public.key</span><br><span class="line">sudo apt-key add public.key</span><br><span class="line"><span class="comment"># 更新</span></span><br><span class="line">sudo apt-get update</span><br><span class="line"><span class="comment"># 安装 钉钉</span></span><br><span class="line">sudo apt-get install dingtalk-electron</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">BluesYoung-web</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://bluesyoung-web.gitee.io/blog/2021-06-12-Linux%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C01.html">https://bluesyoung-web.gitee.io/blog/2021-06-12-Linux%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C01.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://BluesYoung-web.gitee.io/blog" target="_blank">小黑博客</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/%E6%A0%91%E8%8E%93%E6%B4%BE/">树莓派</a><a class="post-meta__tags" href="/blog/tags/linux/">linux</a></div><div class="post_share"></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/blog/img/wx.png" target="_blank"><img class="post-qr-code-img" src="/blog/img/wx.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/blog/img/zfb.jpg" target="_blank"><img class="post-qr-code-img" src="/blog/img/zfb.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/blog/2021-07-28-Linux使用跳板机登录对应的服务器.html" title="Linux使用跳板机登录对应的服务器"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-07-28</div><div class="title">Linux使用跳板机登录对应的服务器</div></div></a></div><div><a href="/blog/2021-08-11-Linux启用SSH服务.html" title="Linux启用SSH服务"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-11</div><div class="title">Linux启用SSH服务</div></div></a></div><div><a href="/blog/2021-08-16-Linux安装you-get.html" title="Linux安装you-get"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-08-16</div><div class="title">Linux安装you-get</div></div></a></div><div><a href="/blog/2021-05-16-Linux开机自启与内存管理.html" title="Linux开机自启与内存管理"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-05-16</div><div class="title">Linux开机自启与内存管理</div></div></a></div><div><a href="/blog/2021-04-10-树莓派使用Samba.html" title="树莓派使用Samba"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-04-10</div><div class="title">树莓派使用Samba</div></div></a></div><div><a href="/blog/2021-04-18-树莓派使用ftp.html" title="树莓派使用ftp"><img class="cover" src="/blog/img/shumeipai_cover.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-04-18</div><div class="title">树莓派使用ftp</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/blog/img/lufei_siwangningshi.jpg" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">BluesYoung-web</div><div class="author-info__description">一枚不善言辞的技术宅</div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">153</div></a></div><div class="card-info-data-item"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">54</div></a></div><div class="card-info-data-item"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">48</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/BluesYoung-web"><i class="fab fa-gitee"></i><span>点个小星星吧</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/BluesYoung-web" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:15171255945@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="移动端软键盘导致布局错乱"/></a><div class="content"><a class="title" href="/blog/2021-08-24-%E7%A7%BB%E5%8A%A8%E7%AB%AF%E8%BD%AF%E9%94%AE%E7%9B%98%E5%AF%BC%E8%87%B4%E5%B8%83%E5%B1%80%E9%94%99%E4%B9%B1.html" title="移动端软键盘导致布局错乱">移动端软键盘导致布局错乱</a><time datetime="2021-08-24T10:01:20.000Z" title="发表于 2021-08-24 18:01:20">2021-08-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux安装you-get"/></a><div class="content"><a class="title" href="/blog/2021-08-16-Linux%E5%AE%89%E8%A3%85you-get.html" title="Linux安装you-get">Linux安装you-get</a><time datetime="2021-08-16T08:07:31.000Z" title="发表于 2021-08-16 16:07:31">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="git删除远程仓库的提交"/></a><div class="content"><a class="title" href="/blog/2021-08-16-git%E5%88%A0%E9%99%A4%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E6%8F%90%E4%BA%A4.html" title="git删除远程仓库的提交">git删除远程仓库的提交</a><time datetime="2021-08-16T07:52:02.000Z" title="发表于 2021-08-16 15:52:02">2021-08-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏"><img src="/blog/img/skill.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="将pad扩展为电脑的副屏"/></a><div class="content"><a class="title" href="/blog/2021-08-13-%E5%B0%86pad%E6%89%A9%E5%B1%95%E4%B8%BA%E7%94%B5%E8%84%91%E7%9A%84%E5%89%AF%E5%B1%8F.html" title="将pad扩展为电脑的副屏">将pad扩展为电脑的副屏</a><time datetime="2021-08-13T11:44:04.000Z" title="发表于 2021-08-13 19:44:04">2021-08-13</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务"><img src="/blog/img/shumeipai_cover.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Linux启用SSH服务"/></a><div class="content"><a class="title" href="/blog/2021-08-11-Linux%E5%90%AF%E7%94%A8SSH%E6%9C%8D%E5%8A%A1.html" title="Linux启用SSH服务">Linux启用SSH服务</a><time datetime="2021-08-11T10:50:04.000Z" title="发表于 2021-08-11 18:50:04">2021-08-11</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By BluesYoung-web</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/blog/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script></div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script> <script src="/blog/js/xkTool.js"></script> <script src="/blog/js/mySelf.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script></div></body></html>